<div class="modal-header page">


        <h3 ng-if="isUnique && gridData.length === 1">{{translateWithTETName('tracked_entity_instance_unique_found_header')}}</h3>
        <h3 ng-if="isUnique && gridData.length > 1">{{translateWithTETName('tracked_entity_instance_search_results_header')}}</h3>
        <h3 ng-if="!isUnique && gridData">{{translateWithTETName('tracked_entity_instance_search_results_header')}}</h3>
        <h3 ng-if="!gridData && !tooManySearchResults && !error">{{translateWithTETName('no_tracked_entity_instance_found_header', true)}}</h3>
        <h3 ng-if="tooManySearchResults">{{'too_many_search_results' | translate}}</h3>
    </div>
    <div class="modal-body page">
        <div ng-if="!gridData">
            <span ng-if="!gridData && !tooManySearchResults && !error">
                    <span ng-if="canOpenRegistration">
                        {{translateWithTETName(translateWithTETName('no_tracked_entity_instance_found_go_to_registration_description',true),true)}}
                    </span>
                    <span ng-if="!canOpenRegistration">
                        {{translateWithTETName('no_tracked_entity_instance_found_description',true)}}
                    </span>
                    
            </span>
            <span ng-if="tooManySearchResults">
                    {{translateWithTETName('large_number_of_search_results_warning')}}
            </span>
            <span ng-if="error">
                {{translateWithTETName('error')}}
            </span>
        </div>
        <div ng-if="gridData && notInSameScope">
                {{translateWithTETName('no_tracked_entity_instance_found_in_selected_program_showing_results_from_other_programs',true)}}
        </div>
        <br/>
        <div ng-if="gridData">
                <tracker-tei-list-performant
                    tei-data="gridData"
                    on-tei-clicked="openTei(tei)"
                    allow-flag-duplicates="true"
                    tei-refetch-data="refetchData(pager, sortColumn)"
                    on-mark-duplicate="markPotentialDuplicate(tei)"
                    on-un-mark-duplicate="unMarkPotentialDuplicate(tei)"
                    on-get-duplicate="getPotentialDuplicate(tei)"
                    tei-pager="pager"
                >
            </tracker-tei-list-performant>
        </div>

    </div>
    <div class="modal-footer page modal-search-bottom">   
        <div class="modal-search-bottom-text">
                <span ng-if="isUnique && gridData && !orgUnitLoading">
                        {{translateWithOULevelName(translateWithTETName('tracked_entity_instance_unique_found_description', true), uniqueTei.orgUnit,true)}}
                </span>
                <span ng-if="!isUnique && gridData && canOpenRegistration">
                        {{translateWithTETName('tracked_entity_instance_search_matches_description', true)}}
                </span>
        </div>
        <div class="modal-search-bottom-buttons">
                <button class="btn btn-default" data-ng-click="cancel()">{{'back'| translate}}</button>
                <button type="button" class="btn btn-primary" ng-if="isUnique" ng-click="openTei(uniqueTei)">{{'open'| translate}}</button>
                <button type="button" class="btn btn-primary" ng-if="canOpenRegistration && (!gridData || !isUnique)" ng-click="openRegistration()">{{'go_to_registration'| translate}}</button>
        </div>
    </div> 